package com.jd.bluej.dubboj.aspect;

import javax.servlet.http.HttpServletResponse;

import org.aspectj.lang.annotation.After;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Pointcut;

import com.alibaba.dubbo.rpc.RpcContext;

/**
 * 
 * Created by bluej on
 * 
 */
@Aspect
public class ResponseAspect {
	
	@Pointcut("execution(* com.jd.bluej.dubboj.service.UserService*.*(..))")
	public void pointCut(){}
	
	@After("pointCut()")
	public void after(){
		if (RpcContext.getContext().getResponse(HttpServletResponse.class) != null) {  
            RpcContext.getContext().getResponse(HttpServletResponse.class).addHeader("Access-Control-Allow-Origin","*"); 
            System.out.println("---ResponseAspect.after()--设置header信息---------");
        }
	}

}
